<!DOCTYPE html>
<html lang="en" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common :: header('编辑会员')"/>
</head>
<body>
<form action="" class="layui-form">
    <div class="mainBox">
        <div class="main-container">

            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="nickname" name="nickname" placeholder="请输入昵称"
                           type="text" th:value="${item.nickname}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="username" name="username" placeholder="请输入姓名"
                           type="text" th:value="${item.username}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="phone" name="phone" placeholder="请输入手机号"
                           type="text" th:value="${item.phone}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input checked name="status" title="禁用" type="radio" value="0" th:checked="${item.status eq 0}">
                    <input name="status" title="正常" type="radio" value="1" th:checked="${item.status eq 1}">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="remark" placeholder="请输入备注"
                              th:text="${item.remark}"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" th:value="${item.id}">
                    <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                </div>
            </div>
        </div>
    </div>
</form>
</body>

<th:block th:include="common :: footer"/>
<script>
    layui.use(['form', 'jquery', 'layer'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let layer = layui.layer;

        form.on('submit(formDemo)', function (data) {
            $.ajax({
                url: '/admin/role/editPost',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("slide-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })

</script>
</html>